from time import sleep

from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


class MouseEvent:
    def __init__(self,driver):
        self.driver = driver

    def scroll_to_element(self,getXPath):
            se = self.driver.find_element(By.XPATH,getXPath)
            self.driver.execute_script("arguments[0].scrollIntoView(true);", se)

    def mouseClick(self,getXPath):
        getClickElement = None
        self.scroll_to_element(getXPath)
        print(getXPath)
        getClickElement = self.driver.find_element(By.XPATH,getXPath)
        getClickElement.click()
        sleep(2)

    def mouseHover(self,getXPath):
        getUserPic = None
        actions = ActionChains(self.driver)
        getUserPic = self.driver.find_element(By.XPATH, getXPath)
        actions.move_to_element(getUserPic).perform()
        sleep(2)
    def mouse_move_0(self):
        actions = ActionChains(self.driver)
        actions.move_by_offset(0, 0).perform()